package io;

import java.io.Serializable;

/**
 * @author Cheng Jun
 * Description:
 * 想要序列化对象，其类必须实现序列化标识接口
 * 如果父类实现序列化，那么子类也是可以序列化的。
 * static 字段不被序列化
 * transient 瞬态，表示不被序列
 * @version 1.0
 * @date 2022/8/14 15:53
 */
public class Student implements Serializable {
    // protected 让子类也能继承 serialVersionUID
    protected static final long serialVersionUID = 1L;
    // static 字段不被序列化
    private static String schoolName = "二中";
    private String name;
    private Integer age;
    // transient 瞬态，表示不被序列。
    private transient String className = "三年级二班";

    public Student(String name, Integer age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }
}
